package ferp.core.ai.strategy.simple;

import ferp.core.card.Card;
import ferp.core.game.Bid;
import ferp.core.log.Log;
import ferp.core.player.Hand;
import ferp.core.player.Player;

/**
 * User: igorgok
 * Date: 5/30/11 1:53 PM
 */
public class Estimate
{
  // get number of misere tricks for specific suit
  public static int misereSuit(int hash) {return misere[hash];}

  // get number of misere tricks for whole hand
  public static int misereHand(int hash)
  {
    int tricks = 0;

    for (Card.Suit s : Card.Suit.rising)
      tricks += misereSuit(Hand.get(hash, s));

    return tricks;
  }

  // estimate max bid for tricks game (10 cards hash)
  public static Bid tricks(int hash, boolean isStarting)
  {
    Bid bid = Bid.play(Card.Suit.NONE, 0);
    int max = 0, h = 0;

    // reverse cards for each suit to solve for the highest ranked downwards
    for (Card.Suit s : Card.Suit.rising)
    {
      // work on copy of the set to prevent its changing
      int set = Hand.get(hash, s);
      int size = Card.Suit.length(set);

      // longest suit will be trump unless there are 2 longest suits, then the trump will be determined
      // by their hash value depending on the first hand
      if (size > max || (size == max && set < h && isStarting))
      {
        max = size;
        h = set;

        bid.trump = s;
      }

      // count raw tricks
      bid.t10000 += tricks[set];
    }

    // no longest suit - choose no trump
    if (max == 3)
      bid.trump = Card.Suit.NONE;

    // perform higher cost game corrections
    if (bid.trump != Card.Suit.NONE)
      switch (round(bid.t10000))
      {
        case 10:
        case 9:
          if (potentialThirdQueen(hash, bid.trump))
            bid.tricks--;

          if (potentialFourthJack(hash, bid.trump))
            bid.tricks--;
          break;

        case 8:
          if (potentialThirdQueen(hash, bid.trump))
            bid.tricks--;
          break;
      }

    bid.tricks += round(bid.t10000);
    //Log.debug(Log.TAG, String.format("%s's estimated tricks %d%s", p.name(), bid.tricks, bid.trump));

    return bid;
  }

  // estimate number of tricks for whisting
  protected static int whists(Player ai, int cards, Card.Suit trump)
  {
    float whists = 0;

    for (Card.Suit s : Card.Suit.rising)
    {
      int set = Hand.get(cards, s);
      whists += s == trump ? Whists.trump[set] : Whists.regular[set];
    }

    Log.debug(Log.TAG, String.format("%s's estimated total whists %f", ai.name(), whists));

    return Math.round(whists);
  }

  protected static int whistsInTrump(Player ai, int cards, Card.Suit trump)
  {
    float whists = trump == Card.Suit.NONE ? 0 : Whists.trump[Hand.get(cards, trump)];

    Log.debug(Log.TAG, String.format("%s's estimated whists in trump %s %f", ai.name(), trump, whists));

    return Math.round(whists);
  }

  // estimate number of tricks for passing
  protected static int passes(int cards)
  {
    // rule of thumb 1: assume the actual number of tricks will be 1 less than the estimated sum
    float tricks = -1;
    int missing = 0;

    // sum up estimated tricks in each suit
    for (Card.Suit s : Card.Suit.rising)
    {
      int cs = Hand.get(cards, s);

      // count missing suits
      if (cs == 0)
        ++missing;
      else
        tricks += passes[cs];
    }

    // adjust according to the number of missing suits
    // rule of thumb 2: 1 missing suit  -> 2 tricks less
    //                  2 missing suits -> 4 tricks less
    tricks -= missing * 2;

    return tricks < 0 ? 0 : (int)Math.floor(tricks);
  }

  private static int round(int v10000)
  {
    // remove "fraction" part
    int f = v10000 / 10000 * 10000;

    // round "up" while ignoring suit size
    return (v10000 - f > 3009 ? f + 10000 : f) / 10000;
  }

  private static boolean potentialThirdQueen(int hash, Card.Suit trump)
  {
    int set = Hand.get(hash, trump);
    int size = Hand.size(set);

    return ((size == 4 || size == 5) &&
            (Hand.contains(set, Card.Mask.ACE) && Hand.contains(set, Card.Mask.KING) && !Hand.contains(set, Card.Mask.QUEEN)));
  }

  private static boolean potentialFourthJack(int hash, Card.Suit trump)
  {
    int set = Hand.get(hash, trump);
    int size = Hand.size(set);

    return size == 4 && Hand.contains(set, Card.Mask.ACE) && Hand.contains(set, Card.Mask.KING) && Hand.contains(set, Card.Mask.QUEEN) && !Hand.contains(set, Card.Mask.JACK);
  }

  // suit sizes
  private static final int S1 = 1;
  private static final int S2 = 2;
  private static final int S3 = 3;
  private static final int S4 = 4;
  private static final int S5 = 5;
  private static final int S6 = 6;
  private static final int S7 = 7;
  private static final int S8 = 8;

  // Estimated tricks per suit
  // Integer values here serve as a replacement for float/double who suffer from precision errors
  // Example: 18000 + S5 -> 1.8 tricks with suit length 5 (18005)
  // Only the first 3 digits represent the number of estimated tricks in a suit.
  // The last 2 digits are reserved and can not be a part of the trick fraction.
  private final static int[] tricks = {
      0,
      0 + S1,  // 7
      0 + S1,  // 8
      0 + S2,  // 8, 7
      0 + S1,  // 9
      0 + S2,  // 9, 7
      0 + S2,  // 9, 8
      0 + S3,  // 9, 8, 7
      0 + S1,  // 10
      0 + S2,  // 10, 7
      0 + S2,  // 10, 8
      0 + S3,  // 10, 8, 7
      0 + S2,  // 10, 9
      0 + S3,  // 10, 9, 7
      0 + S3,  // 10, 9, 8
      1000 + S4,  // 10, 9, 8, 7
      0 + S1,  // J
      0 + S2,  // J, 7
      0 + S2,  // J, 8
      0 + S3,  // J, 8, 7
      0 + S2,  // J, 9
      0 + S3,  // J, 9, 7
      0 + S3,  // J, 9, 8
      1500 + S4,  // J, 9, 8, 7
      0 + S2,  // J, 10
      0 + S3,  // J, 10, 7
      0 + S3,  // J, 10, 8
      1500 + S4,  // J, 10, 8, 7
      0 + S3,  // J, 10, 9
      1500 + S4,  // J, 10, 9, 7
      1500 + S4,  // J, 10, 9, 8
      18000 + S5,  // J, 10, 9, 8, 7
      0 + S1,  // Q
      0 + S2,  // Q, 7
      0 + S2,  // Q, 8
      2000 + S3,  // Q, 8, 7
      0 + S2,  // Q, 9
      2000 + S3,  // Q, 9, 7
      2000 + S3,  // Q, 9, 8
      8500 + S4,  // Q, 9, 8, 7
      0 + S2,  // Q, 10
      2000 + S3,  // Q, 10, 7
      2000 + S3,  // Q, 10, 8
      8500 + S4,  // Q, 10, 8, 7
      2000 + S3,  // Q, 10, 9
      8500 + S4,  // Q, 10, 9, 7
      8500 + S4,  // Q, 10, 9, 8
      18500 + S5,  // Q, 10, 9, 8, 7
      0 + S2,  // Q, J
      2500 + S3,  // Q, J, 7
      2500 + S3,  // Q, J, 8
      8000 + S4,  // Q, J, 8, 7
      2500 + S3,  // Q, J, 9
      8000 + S4,  // Q, J, 9, 7
      8000 + S4,  // Q, J, 9, 8
      28000 + S5,  // Q, J, 9, 8, 7
      10000 + S3,  // Q, J, 10
      20000 + S4,  // Q, J, 10, 7
      20000 + S4,  // Q, J, 10, 8
      30000 + S5,  // Q, J, 10, 8, 7
      20000 + S4,  // Q, J, 10, 9
      30000 + S5,  // Q, J, 10, 9, 7
      30000 + S5,  // Q, J, 10, 9, 8
      43000 + S6,  // Q, J, 10, 9, 8, 7
      0 + S1,  // K
      500 + S2,  // K, 7
      500 + S2,  // K, 8
      3000 + S3,  // K, 8, 7
      500 + S2,  // K, 9
      3000 + S3,  // K, 9, 7
      3000 + S3,  // K, 9, 8
      8000 + S4,  // K, 9, 8, 7
      500 + S2,  // K, 10
      3000 + S3,  // K, 10, 7
      3000 + S3,  // K, 10, 8
      8000 + S4,  // K, 10, 8, 7
      3000 + S3,  // K, 10, 9
      8000 + S4,  // K, 10, 9, 7
      8000 + S4,  // K, 10, 9, 8
      28000 + S5,  // K, 10, 9, 8, 7
      500 + S2,  // K, J
      3000 + S3,  // K, J, 7
      3000 + S3,  // K, J, 8
      8000 + S4,  // K, J, 8, 7
      3000 + S3,  // K, J, 9
      8000 + S4,  // K, J, 9, 7
      8000 + S4,  // K, J, 9, 8
      28000 + S5,  // K, J, 9, 8, 7
      10500 + S3,  // K, J, 10
      18000 + S4,  // K, J, 10, 7
      18000 + S4,  // K, J, 10, 8
      31000 + S5,  // K, J, 10, 8, 7
      21000 + S4,  // K, J, 10, 9
      32000 + S5,  // K, J, 10, 9, 7
      32000 + S5,  // K, J, 10, 9, 8
      49000 + S6,  // K, J, 10, 9, 8, 7
      10000 + S2,  // K, Q
      10500 + S3,  // K, Q, 7
      10500 + S3,  // K, Q, 8
      22000 + S4,  // K, Q, 8, 7
      10500 + S3,  // K, Q, 9
      22000 + S4,  // K, Q, 9, 7
      22000 + S4,  // K, Q, 9, 8
      39000 + S5,  // K, Q, 9, 8, 7
      10600 + S3,  // K, Q, 10
      22200 + S4,  // K, Q, 10, 7
      22200 + S4,  // K, Q, 10, 8
      39500 + S5,  // K, Q, 10, 8, 7
      22400 + S4,  // K, Q, 10, 9
      39000 + S5,  // K, Q, 10, 9, 7
      39000 + S5,  // K, Q, 10, 9, 8
      51000 + S6,  // K, Q, 10, 9, 8, 7
      20000 + S3,  // K, Q, J
      29000 + S4,  // K, Q, J, 7
      29100 + S4,  // K, Q, J, 8
      40000 + S5,  // K, Q, J, 8, 7
      29500 + S4,  // K, Q, J, 9
      40000 + S5,  // K, Q, J, 9, 7
      40000 + S5,  // K, Q, J, 9, 8
      50000 + S6,  // K, Q, J, 9, 8, 7
      30000 + S4,  // K, Q, J, 10
      40000 + S5,  // K, Q, J, 10, 7
      40000 + S5,  // K, Q, J, 10, 8
      50000 + S6,  // K, Q, J, 10, 8, 7
      40000 + S5,  // K, Q, J, 10, 9
      50000 + S6,  // K, Q, J, 10, 9, 7
      50000 + S6,  // K, Q, J, 10, 9, 8
      60000 + S6,  // K, Q, J, 10, 9, 8, 7
      10000 + S1,  // A
      10000 + S2,  // A, 7
      10000 + S2,  // A, 8
      10000 + S3,  // A, 8, 7
      10000 + S2,  // A, 9
      10000 + S3,  // A, 9, 7
      10000 + S3,  // A, 9, 8
      11000 + S4,  // A, 9, 8, 7
      10000 + S2,  // A, 10
      10000 + S3,  // A, 10, 7
      10000 + S3,  // A, 10, 8
      11500 + S4,  // A, 10, 8, 7
      10000 + S3,  // A, 10, 9
      11700 + S4,  // A, 10, 9, 7
      11900 + S4,  // A, 10, 9, 8
      36000 + S5,  // A, 10, 9, 8, 7
      10000 + S2,  // A, J
      10500 + S3,  // A, J, 7
      10600 + S3,  // A, J, 8
      20000 + S4,  // A, J, 8, 7
      10700 + S3,  // A, J, 9
      20100 + S4,  // A, J, 9, 7
      20200 + S4,  // A, J, 9, 8
      37000 + S5,  // A, J, 9, 8, 7
      10800 + S3,  // A, J, 10
      20300 + S4,  // A, J, 10, 7
      20400 + S4,  // A, J, 10, 8
      37100 + S5,  // A, J, 10, 8, 7
      20500 + S4,  // A, J, 10, 9
      37200 + S5,  // A, J, 10, 9, 7
      37300 + S5,  // A, J, 10, 9, 8
      55000 + S6,  // A, J, 10, 9, 8, 7
      10500 + S2,  // A, Q
      10600 + S3,  // A, Q, 7
      10700 + S3,  // A, Q, 8
      20000 + S4,  // A, Q, 8, 7
      10800 + S3,  // A, Q, 9
      20100 + S4,  // A, Q, 9, 7
      20200 + S4,  // A, Q, 9, 8
      38000 + S5,  // A, Q, 9, 8, 7
      10900 + S3,  // A, Q, 10
      20200 + S4,  // A, Q, 10, 7
      20300 + S4,  // A, Q, 10, 8
      38100 + S5,  // A, Q, 10, 8, 7
      20400 + S4,  // A, Q, 10, 9
      38200 + S5,  // A, Q, 10, 9, 7
      38300 + S5,  // A, Q, 10, 9, 8
      57000 + S6,  // A, Q, 10, 9, 8, 7
      20200 + S3,  // A, Q, J
      28000 + S4,  // A, Q, J, 7
      28100 + S4,  // A, Q, J, 8
      40500 + S5,  // A, Q, J, 8, 7
      28200 + S4,  // A, Q, J, 9
      40600 + S5,  // A, Q, J, 9, 7
      40700 + S5,  // A, Q, J, 9, 8
      57100 + S6,  // A, Q, J, 9, 8, 7
      30500 + S4,  // A, Q, J, 10
      40700 + S5,  // A, Q, J, 10, 7
      40800 + S5,  // A, Q, J, 10, 8
      57200 + S6,  // A, Q, J, 10, 8, 7
      40900 + S5,  // A, Q, J, 10, 9
      57300 + S6,  // A, Q, J, 10, 9, 7
      57400 + S6,  // A, Q, J, 10, 9, 8
      70000 + S7,  // A, Q, J, 10, 9, 8, 7
      20000 + S2,  // A, K
      20000 + S3,  // A, K, 7
      20100 + S3,  // A, K, 8
      28000 + S4,  // A, K, 8, 7
      20200 + S3,  // A, K, 9
      28100 + S4,  // A, K, 9, 7
      28200 + S4,  // A, K, 9, 8
      49000 + S5,  // A, K, 9, 8, 7
      20300 + S3,  // A, K, 10
      28300 + S4,  // A, K, 10, 7
      28400 + S4,  // A, K, 10, 8
      49100 + S5,  // A, K, 10, 8, 7
      28400 + S4,  // A, K, 10, 9
      49200 + S5,  // A, K, 10, 9, 7
      49300 + S5,  // A, K, 10, 9, 8
      60000 + S6,  // A, K, 10, 9, 8, 7
      20500 + S3,  // A, K, J
      28500 + S4,  // A, K, J, 7
      28600 + S4,  // A, K, J, 8
      49200 + S5,  // A, K, J, 8, 7
      28700 + S4,  // A, K, J, 9
      49300 + S5,  // A, K, J, 9, 7
      49400 + S5,  // A, K, J, 9, 8
      60000 + S6,  // A, K, J, 9, 8, 7
      38000 + S4,  // A, K, J, 10
      49500 + S5,  // A, K, J, 10, 7
      49600 + S5,  // A, K, J, 10, 8
      60000 + S6,  // A, K, J, 10, 8, 7
      49700 + S5,  // A, K, J, 10, 9
      60000 + S6,  // A, K, J, 10, 9, 7
      60000 + S6,  // A, K, J, 10, 9, 8
      70000 + S7,  // A, K, J, 10, 9, 8, 7
      30000 + S3,  // A, K, Q
      38000 + S4,  // A, K, Q, 7
      38100 + S4,  // A, K, Q, 8
      50000 + S5,  // A, K, Q, 8, 7
      38200 + S4,  // A, K, Q, 9
      50000 + S5,  // A, K, Q, 9, 7
      50000 + S5,  // A, K, Q, 9, 8
      60000 + S6,  // A, K, Q, 9, 8, 7
      38300 + S4,  // A, K, Q, 10
      50000 + S5,  // A, K, Q, 10, 7
      50000 + S5,  // A, K, Q, 10, 8
      60000 + S6,  // A, K, Q, 10, 8, 7
      50000 + S5,  // A, K, Q, 10, 9
      60000 + S6,  // A, K, Q, 10, 9, 7
      60000 + S6,  // A, K, Q, 10, 9, 8
      70000 + S7,  // A, K, Q, 10, 9, 8, 7
      40000 + S4,  // A, K, Q, J
      50000 + S5,  // A, K, Q, J, 7
      50000 + S5,  // A, K, Q, J, 8
      60000 + S6,  // A, K, Q, J, 8, 7
      50000 + S5,  // A, K, Q, J, 9
      60000 + S6,  // A, K, Q, J, 9, 7
      60000 + S6,  // A, K, Q, J, 9, 8
      70000 + S7,  // A, K, Q, J, 9, 8, 7
      50000 + S5,  // A, K, Q, J, 10
      60000 + S6,  // A, K, Q, J, 10, 7
      60000 + S6,  // A, K, Q, J, 10, 8
      70000 + S7,  // A, K, Q, J, 10, 8, 7
      60000 + S6,  // A, K, Q, J, 10, 9
      70000 + S7,  // A, K, Q, J, 10, 9, 7
      70000 + S7,  // A, K, Q, J, 10, 9, 8
      80000 + S8   // A, K, Q, J, 10, 9, 8, 7
  };

  // by Yasha
  private static class Whists
  {
    private final static float[] regular = {
        0,0,0,0,0,0,0,0,0,0,                 //0 - 9
        0,0,0,0,0,0,0,0,0,0,                 //10 - 19
        0,0,0,0,0,0,0,0,0,0,                 //20 - 29
        0,0,0,0,0,1,0,1,1,0,                 //30 - 39
        0,1,1,0,1,0,0,0,0,1,                 //40 - 49
        1,0,1,0,0,0,1,0,0,0,                 //50 - 59
        0,0,0,0,0,1,1,1,1,1,                 //60 - 69
        1,0,1,1,1,0,1,0,0,0,                 //70 - 79
        1,1,1,0,1,0,0,0,1,0,                 //80 - 89
        0,0,0,0,0,0,1,1.2f,1.2f,0,           //90 - 99
        1.2f,0,0,0,1,0,0,0,0,0,              //100 - 109
        0,0,1.6f,0,0,0,0,0,0,0,              //110 - 119
        0,0,0,0,0,0,0,0,1,1,                 //120 - 129
        1,1,1,1,1,0,1,1,1,0,                 //130 - 139
        1,0,0,0,1,1,1,0,1,0,                 //140 - 149
        0,0,1,0,0,0,0,0,0,0,                 //150 - 159
        1,1,1,0,1,0,0,0,1,0,                 //160 - 169
        0,0,0,0,0,0,1.5f,0,0,0,              //170 - 179
        0,0,0,0,0,0,0,0,0,0,                 //180 - 189
        0,0,2,1,1,0,1,0,0,0,                 //190 - 199
        1,0,0,0,0,0,0,0,0.8f,0,              //200 - 209
        0,0,0,0,0,0,0,0,0,0,                 //210 - 219
        0,0,0,0,0,0,0,0,0,0,                 //220 - 229
        0,0,0,0,0,0,0,0,0,0,                 //230 - 239
        0,0,0,0,0,0,0,0,0,0,                 //240 - 249
        0,0,0,0,0,0};                        //250 - 255

    private final static float[] trump = {
        0,0,0,0,0,0,0,0,0,0,                        //0 - 9
        0,0,0,0,0,0,0,0,0,0,                        //10 - 19
        0,0,0,1,0,0,0,1,0,1,                        //20 - 29
        1,2,0,0,0,1,0,1,1,1,                        //30 - 39
        0,1,1,1.2f,1,1.5f,1.5f,3,0,1,               //40 - 49
        1,2,1,2,2,3,1,2,2,3,                        //50 - 59
        2,3,3,4,0,1,1,1,1,1,                        //60 - 69
        1,1,1,1,1,1.2f,1,1.2f,1.2f,3,               //70 - 79
        1,1,1,2,1,2,2,3.4f,1,2,                     //80 - 89
        2,3.4f,2.4f,3.6f,3.6f,4,1,2,2,2,            //90 - 99
        2,2,2,4,2,2,2,4,2.5f,4,                     //100 - 109
        4,5,2,3,3,4,3,4,4,5,                        //110 - 119
        3,4,4,5,4,5,5,6,1,1,                        //120 - 129
        1,1,1,1,1,1,1,1,1,1,                        //130 - 139
        1,1,1,3,1,1.2f,1.2f,2,1.2f,2,               //140 - 149
        2,3.6f,1.2f,2,2,3.6f,2.5f,4,4,5,            //150 - 159
        1.2f,1.5f,1.5f,2,1.5f,2,2,3.8f,1.8f,2.2f,   //160 - 169
        2.2f,4,2.4f,4,4.2f,5.2f,2,2.6f,2.6f,4.5f,   //170 - 179
        2.8f,4.6f,4.6f,6,3.5f,4.8f,4.8f,6,5,6,      //180 - 189
        6,7,2,2,2,2,2,2,2.2f,4,                     //190 - 199
        2,2.4f,2.4f,4,2.6f,4,4,5,3,3,               //200 - 209
        3,4,3.4f,4,4,5,4,5,5,6,                     //210 - 219
        5,6,6,7,3,3.4f,3.4f,5,3.4f,5,               //220 - 229
        5,6,3.8f,5,5,6,5,6,6,7,                     //230 - 239
        4,5,5,6,5,6,6,7,5,6,                        //240 - 249
        6,7,6,7,7,8};                               //250 - 255
  }

  // misere tricks by hash table
  private final static int[] misere = {
      0,0,1,0,1,0,1,0,1,1,
      2,0,2,0,1,0,1,1,2,0,
      2,0,1,0,2,1,2,0,2,0, // 20
      1,0,1,1,2,1,2,1,2,0,
      2,1,3,0,3,0,1,0,2,2,
      3,0,3,0,1,0,3,1,2,0, // 50
      2,0,1,0,1,1,2,1,2,1,
      2,0,2,2,3,0,3,0,1,0,
      2,2,3,0,3,0,1,0,3,1,
      2,0,2,0,1,0,2,2,3,1,
      3,1,2,0,3,1,3,0,3,0, // 100
      1,0,3,2,3,0,3,0,1,0,
      3,1,2,0,2,0,1,0,1,1,
      2,1,2,1,2,1,2,2,3,1,
      3,1,2,0,2,2,3,1,3,2,
      2,0,3,2,3,0,3,0,1,0, // 150
      2,2,3,2,3,2,3,0,3,2,
      3,0,3,0,1,0,3,3,4,0,
      4,0,2,0,3,1,2,0,2,0,
      1,0,2,2,3,2,3,2,3,0,
      3,2,3,0,4,0,1,0,3,3, // 200
      4,0,4,0,1,0,3,1,2,0,
      2,0,1,0,3,3,4,1,3,1,
      2,0,4,1,3,0,3,0,1,0,
      4,2,3,0,3,0,1,0,3,1,
      2,0,2,0,1,0};

  private final static float[] passes = {
      0,0,0.2f,0,0.4f,0,0.4f,0,0.4f,0.6f,         //0 - 9
      0.8f,0,1,0,1,0,0.5f,0.5f,0.6f,0,            //10 - 19
      0.7f,0.5f,1,0,1,1,1.5f,0,1.8f,0,            //20 - 29
      2.5f,0,0.8f,0.8f,1,0.5f,0.8f,0.5f,0.7f,0,   //30 - 39
      2,1.8f,2,0,2,0,0.5f,0,2,2,                  //40 - 49
      2,0.3f,2.2f,0.3f,2,0,2.8f,2,2.5f,0,         //50 - 59
      3,0,1,0,0.9f,0.8f,1.2f,1,1.4f,1,            //60 - 69
      2,0,2,2,2.2f,0,2,0,1.5f,0,                  //70 - 79
      2,2,2.2f,0,2.6f,0,1.5f,0,3,2,               //80 - 89
      2.5f,0,2.6f,0,1,0,2,2,2.2f,1.5f,            //90 - 99
      3,1.5f,2,0,3,2,2.2f,0,3,0,                  //100 - 109
      1,0,3,3,3.2f,0,3.5f,0,1,0,                  //110 - 119
      4,2,2.2f,0,3.5f,0,1,0,1,1,                  //120 - 129
      1.2f,1,1.4f,1,1.4f,0.2f,2,2,2.4f,0.2f,      //130 - 139
      2,0.2f,1,0,2,2,2.2f,0.5f,2.4f,0.8f,         //140 - 149
      2,0,3,2,3,0,3,0,1,0,                        //150 - 159
      2,2,2.2f,2,3,2,2.5f,0,3,2.5f,               //160 - 169
      3,0,3.2f,0,1,0,3,3,3.2f,0,                  //170 - 179
      4,0,1.2f,0,3,1,2,0,2,0,                     //180 - 189
      1,0,2,2,2.2f,1.5f,3,1.5f,2.5f,0,            //190 - 199
      3,2.5f,3,0,3,0,1,0,3,2.5f,                  //200 - 209
      3,0,3.2f,0,1.5f,0,4,1.5f,2,0,               //210 - 219
      3,0,1,0,3,2.5f,3,1,3,1,                     //220 - 229
      2.5f,0,4,1.5f,2,0,3,0,1,0,                  //230 - 239
      4,2,2.5f,0,3,0,1,0,3,1,                     //240 - 249
      2,0,2,0,1,0};                               //250 - 255


  public static void main(String[] argv) throws Exception
  {
    int n = 250;

    System.out.println("Tricks length = " + tricks.length);

    for (int i = 0; i < 256; ++i)
      System.out.println("#" + i + ": " + Hand.dump(i) + " -> " + tricks[i]);
/*
    double v = 0.85 + S4;
    BigDecimal d = new BigDecimal("0.85").add(new BigDecimal("0.0004"));

    System.out.println("value " + d + ", double value " + d.doubleValue());
*/
  }
}